import axios, { type ResDataType } from "./index";
/**
 * @description 获取用户信息
 */
export async function getUserInfoService(): Promise<ResDataType> {
  const url = "/api/user/info";
  const data = await axios.get(url);
  return data;
}
/**
 * @description 注册用户信息
 */
export async function registerService(
  username: string,
  password: string,
  nickname?: string
): Promise<ResDataType> {
  nickname = nickname || username;
  const url = "/api/user/register";
  const body = {
    username,
    password,
    nickname,
  };
  const data = await axios.post(url, body);
  return data;
}
/**
 * @description 登录用户信息
 */
export async function loginService(
  username: string,
  password: string
): Promise<ResDataType> {
  const url = "/api/user/login";
  const body = {
    username,
    password,
  };
  const data = await axios.post(url, body);
  return data;
}
